<%@page import="cn.lily.com.enviroment.Enviroment"%>
<%@page import="cn.lily.com.db.DBFactory"%>
<%@page import="cn.lily.com.db.container.reader.DataTable"%>
<%@page import="cn.lily.inst.web.frames.FrameConfig"%>
<%@page import="cn.lily.com.lang.VerifyData"%>
<%@ page contentType="text/html; charset=utf-8" %>
<%@ page import="cn.lily.web.util.context.WebContext" %>
<%@ page import="cn.lily.esb.context.AuthEntity" %>
<%@ include file="/frames/logbegin.jsp" %>
<%
	String skinName = "";
  String contextPath = "";
  AuthEntity authEntity = (AuthEntity) session.getAttribute(WebContext.LOG_AUTH_CONTEXT);
  if (authEntity != null) {
  	skinName = authEntity.getSkinName();
  	contextPath = authEntity.getContextPath();
  }
  FrameConfig.setContextPath(contextPath);
  
  String appid=request.getParameter("appid");
  String vercode=request.getParameter("vercode");
  String baseSql="";
  
  if(authEntity.getOperatorId().equals("9999")){
    baseSql="SELECT * FROM ${schema}.app_menu a WHERE EXISTS (SELECT 1 FROM ${schema}.app_res_menu r WHERE r.APP_ID='"+appid+"' AND r.MENU_ID=a.MENU_ID)";
  }else{
    if(authEntity.getOperEntity().getOperType().equals("1")){
      baseSql="SELECT * FROM ${schema}.app_menu WHERE MENU_ID IN (SELECT MENU_ID FROM ${schema}.app_ver_menu WHERE APP_ID='"+appid+"' AND VER_COD='"+vercode+"') ";
    }else{
      baseSql="SELECT * FROM ${schema}.app_menu WHERE MENU_ID IN (SELECT r.MENU_ID FROM ${schema}.pw_role_res r,${schema}.pw_oper_role o WHERE r.ROLE_ID=o.ROLE_ID " +
          "AND o.OPER_NO='"+authEntity.getOperatorId()+"' " +
          "AND  r.APP_ID='"+appid+"' " +
          "AND r.VER_COD='"+vercode+"')";
    }
  }  
  
  DataTable menuTable=DBFactory.getActionDB().executeQueryTable(baseSql+"  and IS_LEAF=0 AND MENU_LEV='1' order by LEVEL_IDX");
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">
  <meta charset=utf-8>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title><%=FrameConfig.getAppName()%></title>
  <link href="<%=contextPath+FrameConfig.getStylePath()%>/strap/bootstrap.min.css" rel="stylesheet" media="screen">
  <link href="<%=FrameConfig.getCSSPath("app.css") %>" rel="stylesheet" />
  <link href="<%=contextPath+FrameConfig.getStylePath()%>/font-awesome/css/font-awesome.min.css" rel="stylesheet">

</head>
<body>
  <div id="main-left">
    <!--Sidebar content-->
    <div class="sidebar-menu">
      <% 
        while(menuTable.next()){
          %>
          <a href="#menu-<%=menuTable.getString("MENU_ID") %>" class="nav-header menu-first collapsed" data-toggle="collapse"><%=menuTable.getString("MENU_LAB") %></a>
          <%
          DataTable itemTable = DBFactory.getActionDB().executeQueryTable(baseSql+" and IS_LEAF=1 and PAR_MENU_ID='"+menuTable.getString("MENU_ID")+"' order by LEVEL_IDX ");
          if(itemTable.getRecordCount()>0){
            %>
            <ul id="menu-<%=menuTable.getString("MENU_ID") %>" class="nav nav-list collapse menu-second">
              <%
                while(itemTable.next()){
                  %>
                  <%--<li><a href="<%=contextPath%>/UI/portal/dict/dictMain.jsp" target="contentFrame"><%=itemTable.getString("MENU_LAB") %></a></li>--%>
                  <li><a href="<%=contextPath+itemTable.getString("MENU_SRC") %>" target="contentFrame"><%=itemTable.getString("MENU_LAB") %></a></li>
                  <%
                }
              %>
            </ul>
            <%
          }
        }
      
      %>
      <%@ include file="/frames/logend.jsp" %>
    </div>
  </div>
  <div id="main-right">
    <iframe name="contentFrame" src=""  frameborder="0" height="100%" width="100%"></iframe>
  </div>

  <script src="<%=FrameConfig.getBaseJsUrl() %>/common/jquery-1.9.1.min.js"></script>
  <script src="<%=FrameConfig.getBaseJsUrl()%>/strap/bootstrap.min.js"></script>
  <script src="<%=FrameConfig.getJsUrl("app.js")%>"></script>
</body>
</html>

